// Fill out your copyright notice in the Description page of Project Settings.

#include "WorldEntityManagerDriver.h"

void FWorldEntityManagerPool::Add(const FWorldEntity::Ptr& entity)
{
	const FWorldEntityMeta& meta = entity->MetaClass();

	IdMappings[meta.ClassName][entity->ID.Get()] = entity;

	for (FWorldEntityMetaUpIterator it(meta); !it.IsDone(); it.Next())
	{
		TypeMappings[(*it).ClassName].insert(entity);
	}
}

void FWorldEntityManagerPool::Remove(const FWorldEntity::Ptr& entity)
{
	const FWorldEntityMeta& meta = entity->MetaClass();

	IdMappings[meta.ClassName].erase(entity->ID.Get());

	for (FWorldEntityMetaUpIterator it(meta); !it.IsDone(); it.Next())
	{
		TypeMappings[(*it).ClassName].erase(entity);
	}
}
